def filter_ip(filename,add,deltete):
    print('输入文件名：%s' % filename)
    lis = []
    if add is not None:
        for x in add:
            with open(filename,'r') as f:
                [lis.append(ip) for ip in f.readlines() if x in ip ]
    if deltete is not None:
        for x in deltete:
            [lis.remove(ip) for ip in lis if x in ip]
    mkformat(set(lis))
def mkformat(ips):
    import  re
    pattern = re.compile(r'\d+\.\d+\.\d+\.\d+\s+\d+\.\d+\.\d+\.\d+')
    lis = [re.sub('\s+','-',re.findall(pattern,x)[0]) for x in ips if re.match(pattern, x) is not None]
    with open('ip.txt','w') as f:
        [f.write(x+'\n') for x in lis]
if __name__ == '__main__':
    import Argu
    filter_ip(Argu.args.filename,Argu.args.a,Argu.args.d)
    # system('masscan.exe -p%s --rate=%d  -iL ip.txt --output-status=open -oX result.xml' % (','.join(args.p),args.t))
    # system('masscan -c config.ini')

    '''
    location = ''
    BlackList = []
    
    '''